#ifndef OMPTYPES_H_
#define OMPTYPES_H_

#include "../../Common/Consts.h"
#include <string>
#include <set>
#include <vector>

using namespace std;
using std::string;

#define MAX_FILTERS_X_CONSTR 18

/*
enum TypeEnum {
  INT=0,
  STRING=1
};
*/
typedef ValType TypeEnum;

typedef unsigned char OMPType; //RIDEFINITO

/*
enum OpEnum {
  EQ=0,		// Equals (numbers+strings)
  LT=1,		// Less then (numbers)
  GT=2,		// Greater than (numbers)
  DF=3,		// Different From (numbers+strings)
  IN=4,		// Contains (strings)
  PF=5		// Prefix (strings)
};
*/
typedef Op OpEnum;

typedef unsigned int BFilter;

typedef unsigned char OMPOp; //RIDEFINITO

typedef struct OMPValueStruct {
  int intVal;
  char stringVal[STRING_VAL_LEN];
  OMPType type;
} OMPValue;

typedef struct OMPAttributeStruct {
  char name[NAME_LEN];
  OMPValue value;
} OMPAttribute;

typedef struct OMPMessageStruct {
  OMPAttribute attributes[MAX_ATTR_NUM];
  int numAttributes;
} OMPMessage;

typedef struct OMPConstraintStruct {
  char name[NAME_LEN];
  OMPOp op;
  OMPValue value;
} OMPConstraint;

typedef struct OMPFilterStruct {
  OMPConstraint constraints[MAX_CONSTR_NUM];
  int numConstraints;
  int interface;
  //*** MIA AGGIUNTA ***/
  float window;
  int occurrence;
  //*** FINE MIA AGGIUNTA ***/
} OMPFilter;

typedef struct InnerOMPConstraintStruct {
  OMPOp op;
  OMPValue value;
  vector<int> *filtersVec;
} InnerOMPConstraint;

typedef struct IntOMPConstraintStruct {
  OMPOp op;
  int value;
  int filter;
} IntOMPConstraint;

typedef struct StringOMPConstraintStruct {
  OMPOp op;
  char value[STRING_VAL_LEN];
  int filter;
} StringOMPConstraint;

typedef struct IntOMPConstraintStruct2 {
  unsigned char numFilterIdx;
  OMPOp op;
  int value;
  int filter[MAX_FILTERS_X_CONSTR];
} IntOMPConstraint2;

typedef struct StringOMPConstraintStruct2 {
  unsigned char numFilterIdx;
  OMPOp op;
  char value[STRING_VAL_LEN];
  int filter[MAX_FILTERS_X_CONSTR];
} StringOMPConstraint2;

typedef struct IntOMPConstraintStruct3 {
  OMPOp op;
  int value;
  int filter;
} IntOMPConstraint3;

typedef struct StringOMPConstraintStruct3 {
  OMPOp op;
  char value[STRING_VAL_LEN];
  int filter;
} StringOMPConstraint3;

typedef struct OMPInputStruct {
  OMPValue values[MAX_ATTR_NUM];
  InnerOMPConstraint *constraints[MAX_ATTR_NUM];
  int constraintsSize[MAX_ATTR_NUM];
  int constraintsNum;
} OMPInput;

typedef struct OMPInputStruct2 {
  OMPValue values[MAX_ATTR_NUM];
  void *constraints[MAX_ATTR_NUM];
  int constraintsSize[MAX_ATTR_NUM];
  int constraintsNum;
} OMPInput2;

typedef struct OMPInputStruct3 {
  BFilter nameFilter;
  OMPValue values[MAX_ATTR_NUM];
  BFilter *constrNames[MAX_ATTR_NUM];
  void *constraints[MAX_ATTR_NUM];
  int constraintsSize[MAX_ATTR_NUM];
  int constraintsNum;
} OMPInput3;

typedef struct OMPFilterInfoStruct {
  unsigned char numConstraints;
  unsigned char interface;
  //*** MIA AGGIUNTA ***/
  float window;
  int occurrence;
  //*** FINE MIA AGGIUNTA ***/
} OMPFilterInfo;

typedef struct OMPOutboxStruct {
  OMPMessage *message;
  set<int> outgoingInterfaces;
  //*** MIA AGGIUNTA ***/
  float ws;
  int ns;
  float last;
  //*** FINE MIA AGGIUNTA ***/
} OMPOutbox;

#endif /*OMPTYPES_H_*/
